package com.humh.library.model;


// 罚金类
public class Fine {

  private double amount; // 罚款金额
  private boolean isPaid;  // 是否已支付

  public Fine(double amount) {
    this.amount = amount;
    this.isPaid = true;
  }

  /**
   * 判断罚款是否已支付
   */
  public boolean isPaid() {
    return isPaid;
  }

  /**
   * 支付罚款
   */
  public void payFine(double amount) {

    if (amount > this.amount) { // 如果输入的罚款金额大于当前罚款金额, 则只支付部分
      this.amount = 0; // 罚金清零
      isPaid = false;
      System.out.println("Fine of " + amount + " has been paid.");
    } else {
      isPaid = true;
      System.out.println("Fine is already paid.");
    }

  }

  // Getters and Setters
  public double getAmount() {
    return amount;
  }

  public void setAmount(double amount) {
    this.amount += amount;
  }
}
